home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
6584
/
6584.xpi
/
chrome
/
flashvideodownloader
/
content
/
options.js
< prev
next >
Wrap
Text File
|
2009-11-18
|
3KB
|
95 lines
var FlashVDOptions = {
options : null,
_hotkey : null, // need to store edited values to handle "ok"
_hot_mod: null,
init : function()
{
this.options = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("FlashVD.options.");
var hotkey;
var hot_mod;
var opt_sel_k=window.document.getElementById('opt_hotk');
var opt_sel_m=window.document.getElementById('opt_hotm');
try{hotkey=this.options.getCharPref('hotkey');}catch(e){}
try{hot_mod=this.options.getCharPref('hot_mod');}catch(e){}
if(hotkey)
{
opt_sel_k.selectedItem=opt_sel_k.getElementsByAttribute("label",hotkey)[0];
this._hotkey = hotkey;
}
else
{
opt_sel_k.selectedItem=opt_sel_k.getElementsByAttribute("label","L")[0];
}
if(hot_mod)
{
var tikva;
if(hot_mod=='alt any control')tikva=" alt";
if(hot_mod=='shift any control')tikva="shift";
opt_sel_m.selectedItem=opt_sel_m.getElementsByAttribute("label",tikva)[0];
this._hot_mod = hot_mod;
}
else
{
opt_sel_m.selectedItem=opt_sel_m.getElementsByAttribute("label"," alt")[0];
}
window.sizeToContent();
},
set_hotk : function(){
this._hotkey = window.document.getElementById('opt_hotk').selectedItem.value;
},
set_hotm : function(){
var modifier=window.document.getElementById('opt_hotm').selectedItem.value;
var tikva;
if(modifier=='alt'){tikva='alt any control';}
if(modifier=='shift'){tikva='shift any control';}
this._hot_mod = tikva;
},
get_folder : function() {
var folder = this.onPickFolder();
if (folder)
this.set_folder(folder);
},
set_folder : function(folder) {
window.document.getElementById('fav_folder_text').value=folder;
},
onPickFolder : function(){
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker);
fp.init(window,'Choose folder for videos and games:', Components.interfaces.nsIFilePicker.modeGetFolder);
var res = fp.show();
if (res == Components.interfaces.nsIFilePicker.returnOK)
return fp.file.path;
return false;
},
acceptEdit : function () {
// current logic is too complicated to use preference for hotkeys - refactoring neded
if (this._hotkey != null) this.options.setCharPref('hotkey', this._hotkey);
if (this._hot_mod!= null) this.options.setCharPref('hot_mod',this._hot_mod);
// preference realization doesn't store path if we changed it programmatically (onPickFolder)
var s = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
s.data = window.document.getElementById('fav_folder_text').value;
this.options.setComplexValue("favorite-folder", Components.interfaces.nsISupportsString, s);
},
restore_defaults : function () {
this.options.deleteBranch("");
Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("FlashVD.cache.").deleteBranch("");
window.close();
}
} // FlashVDOptions